<template>
  <div class="empty-state">
    <div class="empty-content">
      <!-- 空状态图片 -->
      <div class="empty-image">
        <img src="@/assets/imgs/blank.png" alt="暂无数据" />
      </div>
      
      <!-- 空状态文本 -->
      <div class="empty-text">
        <h3 class="empty-title">暂无房源数据</h3>
        <p class="empty-description">
          很抱歉，没有找到符合条件的房源<br>
          请尝试调整筛选条件或稍后再试
        </p>
      </div>
      
      <!-- 操作建议 -->
      <div class="empty-actions">
        <el-button type="primary" @click="handleRefresh">
          刷新数据
        </el-button>
        <el-button @click="handleReset">
          重置筛选
        </el-button>
      </div>
      
      <!-- 推荐操作 -->
      <div class="suggestions">
        <h4 class="suggestions-title">您可以尝试：</h4>
        <ul class="suggestions-list">
          <li>调整价格范围</li>
          <li>选择其他区域</li>
          <li>修改户型要求</li>
          <li>联系客服获取更多房源</li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ElMessage } from 'element-plus'

const emit = defineEmits(['refresh', 'reset'])

const handleRefresh = () => {
  ElMessage.info('正在刷新数据...')
  emit('refresh')
}

const handleReset = () => {
  ElMessage.info('已重置筛选条件')
  emit('reset')
}
</script>

<style scoped>
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px 20px;
  background-color: #fff;
  margin: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.empty-content {
  text-align: center;
  max-width: 320px;
}

.empty-image {
  margin-bottom: 24px;
}

.empty-image img {
  width: 120px;
  height: 120px;
  opacity: 0.6;
  filter: grayscale(20%);
}

.empty-text {
  margin-bottom: 24px;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0 0 12px 0;
}

.empty-description {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
  margin: 0;
}

.empty-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}

.empty-actions .el-button {
  min-width: 80px;
}

.suggestions {
  text-align: left;
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 16px;
  border: 1px solid #e9ecef;
}

.suggestions-title {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin: 0 0 12px 0;
}

.suggestions-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.suggestions-list li {
  font-size: 13px;
  color: #666;
  line-height: 1.8;
  position: relative;
  padding-left: 16px;
}

.suggestions-list li::before {
  content: '•';
  color: #409eff;
  font-weight: bold;
  position: absolute;
  left: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .empty-state {
    min-height: 50vh;
    padding: 30px 16px;
    margin: 12px;
  }
  
  .empty-content {
    max-width: 280px;
  }
  
  .empty-image img {
    width: 100px;
    height: 100px;
  }
  
  .empty-title {
    font-size: 16px;
  }
  
  .empty-description {
    font-size: 13px;
  }
  
  .empty-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .empty-actions .el-button {
    width: 100%;
  }
  
  .suggestions {
    padding: 12px;
  }
  
  .suggestions-title {
    font-size: 13px;
  }
  
  .suggestions-list li {
    font-size: 12px;
  }
}

/* 动画效果 */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.empty-content {
  animation: fadeInScale 0.5s ease;
}

.empty-image img {
  transition: transform 0.3s ease;
}

.empty-image:hover img {
  transform: scale(1.05);
}
</style>
